<template>
  <div>
    <div class="pink-area" v-if="info.payGroupVO.groupUserType == 2">
      <div class="flex-sty">
        <div class="list-sty">
          <div class="status-bg">
            <img src="@/assets/images/pay/img18.png" class="icon-img" alt="">
          </div>
          <div class="enter-btn" @click="enterBtn()">{{ $t('goods.group_play_text70') }}</div>
        </div>
        <img src="@/assets/images/pay/img17.png" class="drive-sty" alt="">
        <div class="list-sty">
          <div class="status-bg">
            <img src="@/assets/images/pay/img16.png" class="icon-img" alt="">
          </div>
          <div class="status-text">{{ $t('goods.group_play_text34') }}</div>
        </div>
        <img src="@/assets/images/pay/img12.png" class="drive-sty" alt="">
        <div class="list-sty">
          <div class="status-bg">
            <img src="@/assets/images/pay/img13.png" class="icon-img" alt="">
          </div>
          <div class="status-text">{{ $t('goods.group_play_text11') }}</div>
        </div>
      </div>
    </div>
    <div v-else class="pink-area">
      <div class="flex-sty">
        <div class="list-sty">
          <div class="status-bg">
            <img src="@/assets/images/pay/img14.png" class="icon-img" alt="">
          </div>
          <div class="status-text">{{ $t('goods.group_play_text11') }}</div>
        </div>
        <img src="@/assets/images/pay/img17.png" class="drive-sty" alt="">
        <div class="list-sty">
          <div class="status-bg">
            <img src="@/assets/images/pay/img11.png" class="icon-img" alt="">
          </div>
          <div class="status-text">{{ $t('goods.group_play_text12') }}</div>
        </div>
        <img src="@/assets/images/pay/img12.png" class="drive-sty" alt="">
        <div class="list-sty">
          <div class="status-bg">
            <img src="@/assets/images/pay/img16.png" class="icon-img" alt="">
          </div>
          <div class="status-text">{{ $t('goods.group_play_text13') }}</div>
        </div>
      </div>
    </div>
    <div class="time-sty" v-if="info.payGroupVO.groupUserType == 1">
      <div class="sty-flex">
        <div class="xian-before"></div>
        <div class="time">
          <div class="time-end">
            <div class="rect-bg">{{ hours }}</div>
            <div class="drive-icon">:</div>
            <div class="rect-bg">{{ min }}</div>
            <div class="drive-icon">:</div>
            <div class="rect-bg">{{ sec }}</div>
          </div>
        </div>
        <div class="xian-after"></div>
      </div>
      <div class="text-sty">{{ $t('goods.group_play_text77') }}</div>
    </div>
    <div>
      
    </div>
  </div>
</template>
<script>

export default {
  props: {
    info: {
      type: [String, Object],
      default: () => {
        return {}
      }
    }
  },
  data() {
    return {
      hours: '00',
      min: '00',
      sec: '00',
    }
  },
  watch: {
    info: {
      immediate: true, // 立即触发一次回调，检查初始值
      handler(newVal) {
        if (newVal && newVal.payGroupVO.inviteEndTime) {
          this.countDown(newVal.serverTime, newVal.payGroupVO.inviteEndTime);
        }
      },
    }
  },
  methods: {
    enterBtn() {
      //window.open('https://discord.gg/tyqE6KBvD4', '_blank');
      window.open('https://discord.gg/H5fEeBCY3y', '_blank');
    },
    timeFormat(param) {
      return param < 10 ? '0' + param : param;
    },
    countDown(newTime, endTime) {
      clearInterval(this.interval);
      this.interval = null;
      this.interval = setInterval(() => {
        // 对结束时间进行处理渲染到页面
        let obj = null;
        // 如果活动未结束，对时间进行处理
        if (endTime - newTime > 0) {
          let time = endTime - newTime;
          // 获取时、分、秒
          let hours = parseInt(time / (1000 * 3600));
          let remainingSeconds = time % (1000 * 3600);
          let min = parseInt(remainingSeconds / (1000 * 60));
          let sec = parseInt((remainingSeconds % (1000 * 60)) / 1000);
          obj = {
            hours: this.timeFormat(hours),
            min: this.timeFormat(min),
            sec: this.timeFormat(sec)
          };
          newTime += 1000;
        } else { // 活动已结束，全部设置为'00'
          obj = {
            hours: '00',
            min: '00',
            sec: '00'
          };
          clearInterval(this.interval);
        }
        this.hours = obj.hours;
        this.min = obj.min;
        this.sec = obj.sec;
      }, 1000);
    }
  }
}
</script>
<style lang="less" scoped>
.pink-area {
  min-width: 642px;
  max-width: 880px;
  height: 124px;
  padding: 20px 25px;
  background: #FFEEF4;
  border-radius: 12px 12px 12px 12px;
  margin-top: 16px;

  .flex-sty {
    display: flex;
    justify-content: space-around;

    .list-sty {
      display: flex;
      flex-direction: column;
      align-items: center;
      flex: 1;
      .status-bg {
        width: 48px;
        height: 48px;
        background: #FFFFFF;
        border-radius: 12px 12px 12px 12px;
        display: flex;
        align-items: center;
        justify-content: center;

        .icon-img {
          width: 24px;
          height: 24px;
        }
      }

      .status-text {
        font-family: PingFang SC, PingFang SC;
        font-weight: 500;
        font-size: 18px;
        color: #1E1714;
        line-height: 24px;
        margin-top: 12px;
      }

      .enter-btn {
        padding: 0 10px;
        min-width: 143px;
        height: 30px;
        background: #1E1714;
        border-radius: 22px 22px 22px 22px;
        font-family: PingFang SC, PingFang SC;
        font-weight: 500;
        font-size: 16px;
        color: #FFFFFF;
        line-height: 16px;
        cursor: pointer;
        margin-top: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
      }
    }

    .drive-sty {
      width: 36px;
      height: 10px;
      margin-top: 21px;
    }
  }
}

.time-sty {
  // display: flex;
  // gap: 32px;
  margin-top: 16px;
  min-width: 642px;
  max-width: 880px;
  .sty-flex{
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .xian-before {
    width: 218px;
    height: 0px;
    border-radius: 0px 0px 0px 0px;
    border: 1px solid;
    border-image: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 127, 157, 1)) 2 2;
  }

  .time {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 32px;
    .time-end {
      display: flex;
      align-items: center;
      gap: 12px;

      .rect-bg {
        width: 30px;
        height: 30px;
        background: linear-gradient(346deg, #FF326C 0%, #FF3810 100%);
        border-radius: 5px 5px 5px 5px;
        font-weight: 500;
        font-size: 16px;
        color: #FFFFFF;
        line-height: 19px;
        display: flex;
        align-items: center;
        justify-content: center;
      }

      .drive-icon {
        font-weight: 600;
        font-size: 16px;
        color: #FF326C;
        line-height: 22px;
      }
    }

    
  }
  .text-sty {
    font-family: PingFang SC, PingFang SC;
    font-weight: 400;
    font-size: 16px;
    color: #FF186B;
    line-height: 19px;
    margin-top: 8px;
    text-align: center;
  }
  .xian-after {
    width: 218px;
    height: 0px;
    border-radius: 0px 0px 0px 0px;
    border: 1px solid;
    border-image: linear-gradient(90deg, rgba(255, 127, 157, 1), rgba(255, 255, 255, 0)) 2 2;
  }
}
</style>
